home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Christina Milan AM to PM
/
Christina Milan - AM to PM.iso
/
christin.dir
/
00021_Script_Jump to Marker Button
< prev
next >
Wrap
Text File
|
2001-08-09
|
11KB
|
322 lines
-- DESCRIPTION --
on getBehaviorDescription
return "¼
JUMP TO MARKER BUTTON"&RETURN&RETURN&"¼
A click on the sprite makes the playback head jump to a chosen marker in the ¼
same movie. You can choose between:"&RETURN&"¼
-> previous marker"&RETURN&"¼
-> next marker"&RETURN&"¼
-> any named marker in the movie"&RETURN&RETURN&"¼
If more than one marker has the same name as the chosen marker, the playback ¼
head will jump to the first marker with that name in the movie. If you need ¼
to use duplicate names, try adding a different number of spaces at the end of ¼
each, so that they appear the same but are in fact different."&RETURN&RETURN&"¼
This behavior is designed for use with the 'Jump Back Button'. You can set ¼
it to record the frame number of the current marker so that the 'Jump Back ¼
Button' can subsequently return. NOTE: This feature relies on a global ¼
variable: gNavigationButtonList."&RETURN&RETURN&"¼
Use the 'Jump to Movie Button' behavior to jump to a marker in a ¼
different movie."&RETURN&RETURN&"¼
PERMITTED MEMBER TYPES"&RETURN&"Graphic members"&RETURN&RETURN&"¼
PARAMETERS:"&RETURN&"¼
* Jump to marker in this movie"&RETURN&"¼
* 'Go to' or 'Play and return'?"&RETURN&"¼
* Remember current marker for Back button"&RETURN&RETURN&"¼
Select 'Remember current marker for Back button' to ensure that the behavior ¼
'remembers' which markers have already been visited."&RETURN&RETURN&"¼
Use the associated 'Jump Back Button' behavior on a separate sprite to return ¼
to visited markers in reverse order."&RETURN&RETURN&"¼
ASSOCIATED BEHAVIORS:"&RETURN&"¼
+ Jump to Movie button"&RETURN&"¼
+ Jump Back Button"&RETURN&"¼
+ Jump Forward Button"&RETURN&"¼
+ Push Button (to alter rollover / mouseDown states)"
end getBehaviorDescription
on getBehaviorTooltip
return "¼
Use with graphic members."&RETURN&RETURN&"¼
When you drop this behavior on a sprite,"&RETURN&"¼
you will be invited to choose which marker"&RETURN&"¼
in the current movie to jump to on mouseUp."&RETURN&"¼
You can also choose 'previous' or 'next'."&RETURN&RETURN&"¼
Use this behavior with the 'Jump Back Button'"&RETURN&"¼
to allow the user to return to visited"&RETURN&"¼
sequences."
end getBehaviorTooltip
-- NOTES FOR DEVELOPERS --
-- The main handler is Jump, which is triggered by mouseUp. The Initiialize
-- handler runs a series of error-checks. These will alert designers
-- in any of the following cases:
-- * if the chosen marker has been deleted or renamed
-- * if more than one marker has the same name as the chosen marker
-- * if the global gNavigationButtonList does not have a valid structure
-- USE OF 'BACK/FORWARD BUTTON' BEHAVIORS
--
-- This behavior is designed to be use in collaboration with 'Jump Back' and
-- 'Jump Forward' buttons so that users can retrace their steps.
--
-- Information about what markers have already been visited is stored in a
-- global variable: gNavigationButtonList. As a global, this variable is
-- available to all navigation behaviors, on any sprite in any movie.
--
-- gNavigationButtonList has the following structure:
-- [#stack [...], #index: [...], #forward: [...]]
-- Each of the subLists has the structure:
-- [[#frame: <integer>, #movie: <movieName>], [...]]
--
-- #index is not currently exploited. It provides a list of all markers
-- visited, in the order of their first visit. It could be used to create
-- a pop-up menu, or to check if a player had visited a particular scene.
--
-- Information concerning the most recently visited marker is stored in the
-- last item of the #stack list. This item is copied to a local variable,
-- then removed from the #stack. Information concerning the current marker
-- is appended to the #forward list, so that users can subsequently retrace
-- their steps.
-- HISTORY --
-- 10 September 1998: written for the D7 Behaviors Palette by James Newton
-- 22 October 1998: "play"/"go to" added, error-checking eased to allow
-- authors to use the behavior before creating markers.
-- PROPERTIES --
-- author-defined parameters:
property myMarker
property myJumpMode
property myReturn
-- global gNavigationButtonList -- Only declared if it is to be used
-- EVENT HANDLERS --
on beginSprite me
Initialize me
end beginSprite
on mouseUp me
Jump me
end prepareFrame
-- CUSTOM HANDLERS --
on Initialize me -- sent BY beginSprite
-- Error checking: Marker name
if not getPos ([#next, #previous, #loop], myMarker) then
-- Does myMarker still exist?
theMarkerList = RETURN&the labelList
markerExists = offset (RETURN&myMarker&RETURN, theMarkerList)
if not markerExists then
ErrorAlert me, #markerMissing, myMarker
else
-- Is myMarker still unique?
delete char 1 to markerExists of theMarkerList
if offset (RETURN&myMarker&RETURN, theMarkerList) then
ErrorAlert me, #runtime_DuplicateMarkers, myMarker
end if
end if
end if
-- Error checking: Global variable
if myReturn then
global gNavigationButtonList -- Only declared if it is to be used
if voidP (gNavigationButtonList) then
-- Initialize gNavigationButtonList
gNavigationButtonList = [#stack: [], #forward: [], #index: []]
else -- Is it the right global?
if gNavigationButtonList.ilk <> #propList then
ErrorAlert (me, #invalidGlobal, gNavigationButtonList)
else if not gNavigationButtonList.findPos(#stack) then
ErrorAlert (me, #invalidGlobal, gNavigationButtonList)
else if not gNavigationButtonList.findPos(#index) then
ErrorAlert (me, #invalidGlobal, gNavigationButtonList)
else if not gNavigationButtonList.findPos(#forward) then
ErrorAlert (me, #invalidGlobal, gNavigationButtonList)
end if
end if
end if
-- End of error checking
end Initialize
on Jump me -- sent by mouseUp
case myMarker of
#previous:targetIsNewMarker = (marker (-the maxInteger / 2) <> marker (0))
#loop: targetIsNewMarker = FALSE
#next: targetIsNewMarker = (marker (0) <> marker (the maxInteger / 2))
otherwise
targetIsNewMarker = (marker (0) <> marker (myMarker))
end case
if myReturn and targetIsNewMarker then
-- Remember where to come back to
global gNavigationButtonList -- Only declared if it is to be used
currentMarker = [#frame: marker (0), #movie: the movieName]
-- Add currentMarker to #stack
gNavigationButtonList.stack.append(currentMarker)
-- Check if currentMarker is already in #index
if not gNavigationButtonList.index.getPos(currentMarker) then
gNavigationButtonList.index.append(currentMarker)
end if
-- Empty #forward list
gNavigationButtonList.forward = []
end if
-- Go to frame indicated by myMarker
if myJumpMode = "Go to" then
case myMarker of
#previous: go previous
#loop: go loop
#next: go next
otherwise
go marker (myMarker)
end case
else -- play => play done
case myMarker of
#previous: play marker (-1)
#loop: play marker (0)
#next: play marker (1)
otherwise:
play myMarker
end case
end if
end Jump
-- ERROR CHECKING --
on ErrorAlert me, theError, data
-- Send by getPropertyDescriptionList, initialize
-- Determine the behavior's name
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
-- Convert #data to useful value
case data.ilk of
#void: data = "<void>"
#symbol: data = "#"&data
end case
case theError of
#getPDL_DuplicateMarkers:
alert "¼
Two or more markers in this movie have the same name. This could lead to ¼
confusion if you use this behavior to go to a named marker."&RETURN&RETURN&"¼
Duplicate marker(s) = "&data
#markerMissing:
if the runMode = "Author" then
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&"¼
Behavior "&behaviorName&RETURN&RETURN&"¼
The chosen marker no longer exists. ¼
Choose a valid marker in the Behavior Parmeters dialog."&RETURN&RETURN&"¼
Current marker = "&data
end if
abort
#runtime_DuplicateMarkers:
if the runMode = "Author" then
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&"¼
Behavior "&behaviorName&RETURN&RETURN&"¼
The chosen marker does not have a unique name. The playback head will jump ¼
to the first marker with this name:"&RETURN&RETURN&"¼
Duplicate marker name = "&data
end if
#invalidGlobal:
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&"¼
Behavior "&behaviorName&RETURN&RETURN&"¼
Behavior "&behaviorName&" requires a global gNavigationButtonList with the ¼
structure:"&RETURN&"¼
[#stack [...], #index: [...], #forward: [...]]"&RETURN&RETURN&"¼
Current value = "&data
halt
end case
end ErrorAlert
-- AUTHOR-DEFINED PARAMETERS --
on getPropertyDescriptionList me
if not the currentSpriteNum then exit
currentMember = sprite(the currentSpriteNum).member
markersList = GetMarkers (me)
if markersList.count() = 2 then -- [[<markers>], [<duplicates>]]
ErrorAlert (me, #getPDL_DuplicateMarkers, markersList[2])
end if
return ¼
[ ¼
#myMarker: ¼
[ ¼
#comment: "On mouseUp, jump to marker:", ¼
#format: #marker, ¼
#default: #next ¼
], ¼
#myJumpMode: ¼
[ ¼
#comment: "Jump Mode:", ¼
#format: #string, ¼
#range: ["Go to", "Play and Return"], ¼
#default: "Go to" ¼
], ¼
#myReturn: ¼
[ ¼
#comment: "Remember current marker for Back button?", ¼
#format: #boolean, ¼
#default: TRUE ¼
] ¼
]
end getPropertyDescriptionList
on GetMarkers me -- Sent by getPropertyDescriptionList
localMarkerList = []
duplicatesList = []
markerString = the labelList
delete the last char of markerString
markerCount = the number of lines of markerString
repeat with i = 1 to markerCount
theMarker = markerString.line [i]
if localMarkerList.getPos(theMarker) then
-- Duplicate marker name
if not duplicatesList.getPos(theMarker) then
duplicatesList.append(theMarker)
end if
else
localMarkerList.append(theMarker)
end if
end repeat
if duplicatesList.count() then
return [localMarkerList, duplicatesList]
else
return [localMarkerList]
end if
end GetMarkers